﻿/// <reference path="jquery-1.7.1.js" />


var mode = 1;//显示的模式：1-月视图  29-帮助  34-天视图 59-周视图
var userId;
var isFrist=false;
var $caler;
var $calendarHeader;
var $calendarBody;

$.fn.calendar = function (id) {
    userId=id;
    //整体布局框架
    $caler = $("<div class='caler'><div id='sysMsg'></div><div id='quickLink' style='font-size:14px'>帮助</div></div>");
    $calendarHeader=$("<div class='caler-head'></div>");
    $calendarBody = $("<div class='caler-body'></div>");
    $caler.append($calendarHeader);
    $caler.append($calendarBody);
    $(this).css({ "padding": "0px", "margin": "0px", "overflow": "hidden" });
    $(this).append($caler);

    //splashModule(true);
    loadHeadView();//加载头部
    
    //右键菜单屏蔽替换
    $caler.contextmenu(function () { $("#help").remove();configUI(); return false; });
    
    //浏览器
    var browser=navigator.appName

var b_version=navigator.appVersion

var version=b_version.split(";");

var trim_Version=version[1].replace(/[ ]/g,"");

if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE9.0")

{

    splashModule(true);

}
if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE8.0")

{

    alert("您当前使用的浏览器是IE8 ，部分功能可能不支持。建议您使用IE9或更高版本的浏览器。");

}

if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0")

{

    $caler.html("浏览器版本过低，无法启动所需的模块。请使用IE 8 或更高版本的浏览器。（您的浏览器版本为IE 7）");
    return false;

}

    else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0")

{

    alert("浏览器版本过低，无法启动所需的模块。请使用IE 8 或更高版本的浏览器。（您的浏览器版本为IE 7)");
    return false;

}
    
    
    
    
    $("#sysMsg").ajaxError(function () { splashModule(false); $(this).html("同步异常！无法连接到服务器。"); });

}

///////////////////////////////////////////////////////////////////////////////////////
//公共运行库
//////////////////////////////////////////////////////////////////////////////////////


//刷新头部视图
function loadHeadView() {
    mode = 1;
        monthHeadView();
        loadBodyView();
    navigatorEventRegister();
}

//刷新主体视图
function loadBodyView() {
    mode = 1;
        monthBodyView();
    globalStyle();
}

//视图切换事件处理
function navigatorEventRegister() {
    
    if (mode == 1) {
        var mouseDown = 1; //记录鼠标按下的时长(2-快速 10-高速）
        var timer;
        $("#nav-previous").click(function () {
            $("#currentDate").text(getMonth($("#currentDate").text(), 2));
            loadBodyView();
        }).mousedown(function () {
            timer = setInterval(function () {
                if (mouseDown >= 2) {
                    $("#currentDate").text(getMonth($("#currentDate").text(), 2));
                    loadBodyView();
                }
                mouseDown++;
            }, 300);
        }).mouseup(function () {
            if (mouseDown >= 2) {
                //惯性回滚
                $("#currentDate").text(getMonth($("#currentDate").text(), 1));
                loadBodyView();
            }
            mouseDown = 0;//恢复默认值
                clearInterval(timer);
        }).mouseout(function () {
                mouseDown = 0;
                clearInterval(timer);
        });

        //后翻
        $("#nav-next").click(function () {
            $("#currentDate").text(getMonth($("#currentDate").text(), 1));
            loadBodyView();
        }).mousedown(function () {
            timer = setInterval(function () {
                if (mouseDown >= 2) {
                    $("#currentDate").text(getMonth($("#currentDate").text(), 1));
                    loadBodyView();
                }
                mouseDown++;
            }, 300);
        }).mouseup(function () {
            if (mouseDown >= 2) {
                //惯性回滚
                $("#currentDate").text(getMonth($("#currentDate").text(), 2));
                loadBodyView();
            }
            mouseDown = 0;
            clearInterval(timer);
        }).mouseout(function () {
            mouseDown = 0;
               clearInterval(timer);
            
        });
    }

    
}

///////////////////////////////////////////////////////////////////////////////////////
//月视图
//////////////////////////////////////////////////////////////////////////////////////

//根据时间字符串，返回对应时间。（YYYY-MM或YYYY-MM-DD）
function getDate(date) {
    
    var year = Number(date.substring(0, 4));
    var month;
    var day =1;

    //个位月
    if (isNaN(Number(date.substring(5, 7)))) {

        month = Number(date.substring(5, 6));
        if (date.length >7) {
            //个位天
            if (isNaN(Number(date.substring(7, 9))))
                day = Number(date.substring(7, 8));

                //双位天
            else
                day = Number(date.substring(7, 9));
        }
        
    }
    //双位月
    else {
        month = Number(date.substring(5, 7));
        if (date.length > 8) {
            if (isNaN(Number(date.substring(8, 10))))
                day = Number(date.substring(8, 9));

            else
                day = Number(date.substring(8, 10));
        }
    }

    return new Date(year,month-1,day);
}

//根据操作替换头部日期
//date:日期字符串（YYYY-MM）；mode：行进方向(1-后月 2-前月)
function getMonth(date, mode) {
    var year = getDate(date).getFullYear();
    var month = getDate(date).getMonth()+1;
    if (mode == "1") {
        if (month == 12) {
            year += 1;
            month = 1;
        }
        else {
            month += 1;
        }
    }
    if (mode == "2") {
        if (month == 1) {
            year -= 1;
            month = 12;
        }
        else {
            month -= 1;
        }
    }

    return year + "年" + month + "月";
}

//获取指定日期字符串的年、月、天数、首日星期、结束日星期的数据
//data:YYYY-MM的字符串日期数据（个位月份无需补零）
function getMonthData(data) {

    var year = getDate(data).getFullYear();
    var month = getDate(data).getMonth()+1 ;
    var daysInMonth = 32 - new Date(year, month-1 , 32).getDate();
    var weekdayStart = new Date(year, month-1 , 1).getDay();
    var weekdayEnd = new Date(year, month-1 , daysInMonth).getDay();
    //返回json
    return {"year":year,"month":month,"days":daysInMonth,"begin":weekdayStart,"end":weekdayEnd};
}



//月视图头部
//date 显示的日期 YYYY年MM月 空值取当前月份
function monthHeadView() {
    var theDateOnCurrentView;
    if (isFrist != false)
        theDateOnCurrentView = $("#currentDate").text();
    $calendarHeader.html("");
    $calendarHeader.append("<div class='div-nav-left'><img id='nav-previous' src='images/ArrowHead-Left.png'/></div><div class='div-title'><label id='currentDate'></label></div><div class='div-nav-right'><img id='nav-next' src='images/ArrowHead-Right.png'/></div>");
    
    //赋值当前月份
    if (!isFrist) {
        $("#currentDate").text(new Date().getFullYear() + "年" + (new Date().getMonth() + 1) + "月");
        isFrist = true;
    }
    else
        $("#currentDate").text(theDateOnCurrentView);
}

var rows; //行数

//月视图主体生成
function monthBodyView() {
    $calendarBody.html("");

    //标题
    var weekday = new Array();
    weekday[0] = "星期日";
    weekday[1] = "星期一";
    weekday[2] = "星期二";
    weekday[3] = "星期三";
    weekday[4] = "星期四";
    weekday[5] = "星期五";
    weekday[6] = "星期六";
    
    //生成日期格
    var $table = $("<table class='table-month'></table>");
    var $tr = $("<tr class='tr-title'></tr>");
    for (i = 0; i <7; i++) {
        $tr.append("<td class='month-title'>" + weekday[i] + "</td>");
    }
    $table.append($tr);

    var currentDate = $("#currentDate").text();
    var data = getMonthData(currentDate);//选择月
    var previousData = getMonthData(getMonth(currentDate, 2));//上月
    var nextData = getMonthData(getMonth(currentDate, 1));//下月
    
    var cells = data.days + data.begin + (6 - data.end);

    //循环变量集
    var nowCnt = 1;//当月起始
    var preCnt = previousData.days;//上月天数
    var nextCnt = 1;//下月起始

    rows = cells / 7;
    for (i = 1; i <= rows; i++) {
        $tr = $("<tr></tr>");
        for (j = 0; j < 7; j++) {
            //第一行
            if (i == 1) {
                //用上个月的末尾填充空格
                if (j < data.begin) {
                    
                    $tr.append("<td class='previousMonth' id='" + previousData.year + "-" + previousData.month + "-" + (preCnt + 1 - data.begin) + "'>"  + (preCnt + 1 - data.begin) + "</td>");
                    preCnt++;
                }
                else {

                    $tr.append("<td class='currentMonth' id='" + data.year + "-" + data.month + "-" + nowCnt + "'>"+ nowCnt + "</td>");
                    
                    nowCnt++;
                }

            }
            //最后行
            if (i == cells / 7) {
                if (j > data.end) {
                    $tr.append("<td class='nextMonth' id='" + nextData.year + "-" + nextData.month + "-" + nextCnt + "'>" + nextCnt + "</td>");
                    nextCnt++;
                }
                else {
                    
                    $tr.append("<td class='currentMonth' id='" + data.year + "-" + data.month + "-" + nowCnt + "'>"+ nowCnt + "</td>");
                    
                    nowCnt++;
                }
            }
            if (i != 1 && i != cells / 7) {
                $tr.append("<td class='currentMonth' id='" + data.year + "-" + data.month + "-" + nowCnt + "'>"+ nowCnt +"</td>");
                

                nowCnt++;
            }
        }
        $table.append($tr);
    }

    
    $calendarBody.html($table);
    

    //当日着色
    if (data.month == new Date().getMonth() + 1 && data.year == new Date().getFullYear()) {
        $(".table-month").children().children("tr").each(function () {
            $(this).children(".currentMonth").each(function () {
                if ($(this).html() == new Date().getDate())
                    $(this).removeClass("currentMonth").addClass("currentDay");
            });

        });
    }

    //必须置于方法底端
    fillDayGridServer();
}

//填充数据到日期单元格(脱机XML方式)
function fillDayGridLocation() { }

//填充数据到日期单元格(联机WebService方式)
function fillDayGridServer() {
    $("#sysMsg").html("正在同步数据，这可能需要一点时间...");
    var $tdSet = $(".table-month td[class!='month-title']");
    $tdSet.each(function (idx) {
        var day = $($tdSet[idx]).html();
        $($tdSet[idx]).html("").append("<div class='dayGrid-head'><div class='dayGrid-day'><label>" + day + "</label></div><div class='dayGrid-title'></div></div><div class='note0'><div class='note-time'></div><div class='note-summary'></div></div><div class='note1'><div class='note-time'></div><div class='note-summary'></div></div><div class='note2'><div class='note-time'></div><div class='note-summary'></div></div><div class='index'></index>");

        if ($($tdSet[idx]).attr("class") == "currentDay")
            $($tdSet[idx]).children(".dayGrid-head").css({ "color": "white" });

    });

    analyzingData($tdSet, 0);
    
    styleForMonthGrid();
    
}

//解析单天数据
//tdSet:TD集合 cnt 序列号
function analyzingData(tdSet,cnt) {
    
    var tdElement = $(tdSet)[cnt];
    var tdDate = $(tdElement).attr("id");
    $.ajax({
        url: "NoteDB.asmx/GetNote",
        type: "post",
        data: { "date":tdDate,"user":userId },
        //结果参数（seq:序列字段,note:事项 ，start:起始时间,end:结束时间(YYYY-MM-DD),state:完成情况）
        success: function (result) {
        
            if ($(result).children("string").text() != "[]"&&$(result).children("string").text() != "") {
                var json = eval("(" + $(result).children("string").text() + ")");

                var pretreatmentData;
                if (tdElement.previousSibling) {
                    pretreatmentData = dataPretreatment(json, tdElement);
                }
                else {
                    pretreatmentData = json;
                }
                var valid = 0;

                for (i = 0; i < $(pretreatmentData).length; i++) {
                    //添加定位轴
                    $(tdElement).find(".index").append("<div>" + pretreatmentData[i].pkid + "</div>");

                    if (pretreatmentData[i].pkid != "-1") {
                        valid++;

                        if ($(pretreatmentData).length > 3)
                            $(tdElement).find(".dayGrid-title").html(valid + "个事件");
                        var pkid = $(pretreatmentData)[i].pkid;

                        var start = $(pretreatmentData)[i].start;
                        var end = $(pretreatmentData)[i].end;
                        var note = $(pretreatmentData)[i].note;
                        var state = Number($(pretreatmentData)[i].state);

                        //结束日期大于当前日期且状态为未完成(过期）
                        if (getDate(end) < new Date() && state == 0) {

                            //起始日期不等于结束日期 即多天
                            if ((getDate(start).getFullYear() != getDate(end).getFullYear()) || (getDate(start).getMonth() + 1 != getDate(end).getMonth() + 1) || (getDate(start).getDate() != getDate(end).getDate())) {
                                //开始日期不为当前格子日期不显示内容
                                if (((getDate(start).getFullYear() != getDate($(tdElement).attr("id")).getFullYear()) || (getDate(start).getMonth() + 1 != getDate($(tdElement).attr("id")).getMonth() + 1) || (getDate(start).getDate() != getDate($(tdElement).attr("id")).getDate())) && tdElement.previousSibling)
                                    //如果结束日期等于当前格子的日期 采用单格样式
                                    if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-multi-timeout").attr({ "title": note + "\n" + start + " 到 " + end });
                                    else
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-timeout").attr({ "title": note + "\n" + start + " 到 " + end });

                                else
                                    //如果结束日期等于当前格子的日期 采用单格样式
                                    if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-multi-timeout").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                                    else
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-timeout").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                            }
                            else {
                                $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-timeout").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                            }
                        }

                        //正在进行中的
                        if (getDate(end) > new Date() && state == 0) {

                            //起始日期不等于结束日期 即多天
                            if ((getDate(start).getFullYear() != getDate(end).getFullYear()) || (getDate(start).getMonth() + 1 != getDate(end).getMonth() + 1) || (getDate(start).getDate() != getDate(end).getDate())) {
                                //开始日期不为当前格子日期不显示内容
                                if (((getDate(start).getFullYear() != getDate($(tdElement).attr("id")).getFullYear()) || (getDate(start).getMonth() + 1 != getDate($(tdElement).attr("id")).getMonth() + 1) || (getDate(start).getDate() != getDate($(tdElement).attr("id")).getDate())) && tdElement.previousSibling)
                                    //如果结束日期等于当前格子的日期 采用单格样式
                                    if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-multi-running").attr({ "title": note + "\n" + start + " 到 " + end });
                                    else
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-running").attr({ "title": note + "\n" + start + " 到 " + end });

                                else
                                    //如果结束日期等于当前格子的日期 采用单格样式
                                    if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-multi-running").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                                    else
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-running").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                            }
                            else {
                                $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-running").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                            }
                        }

                        //已完成
                        if (state == 1) {

                            //起始日期不等于结束日期 即多天
                            if ((getDate(start).getFullYear() != getDate(end).getFullYear()) || (getDate(start).getMonth() + 1 != getDate(end).getMonth() + 1) || (getDate(start).getDate() != getDate(end).getDate())) {
                                //开始日期不是格子日期并且不是处于TR内首格则不显示内容
                                if (((getDate(start).getFullYear() != getDate($(tdElement).attr("id")).getFullYear()) || (getDate(start).getMonth() + 1 != getDate($(tdElement).attr("id")).getMonth() + 1) || (getDate(start).getDate() != getDate($(tdElement).attr("id")).getDate())) && tdElement.previousSibling) 
                                    //同上段
                                    if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-multi-finish").attr({ "title": note + "\n" + start + " 到 " + end });
                                    else
                                        $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-finish").attr({ "title": note + "\n" + start + " 到 " + end });

                                
                                else
                                    if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                        $(tdElement).find(".note" + i).removeClass("note" + i).html(note).addClass("note-multi-finish").attr({ "title": note + "\n" + start + " 到 " + end });
                                    else
                                        $(tdElement).find(".note" + i).removeClass("note" + i).html(note).addClass("note-single-finish").attr({ "title": note + "\n" + start + " 到 " + end });
                            }
                            else {
                                //如果结束日期等于当前格子的日期 采用单格样式
                                if ((getDate(end).getFullYear() != getDate(tdDate).getFullYear()) || (getDate(end).getMonth() + 1 != getDate(tdDate).getMonth() + 1) || (getDate(end).getDate() != getDate(tdDate).getDate()))
                                    $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-multi-finish").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                                else
                                    $(tdElement).find(".note" + i).removeClass("note" + i).addClass("note-single-finish").html(note).attr({ "title": note + "\n" + start + " 到 " + end });
                            }
                        }


                        fillNoteStyle();//色块着色 
                    }
                }
            }

            //递归循环调用
            cnt++;
            if (cnt < $(tdSet).length)
                analyzingData(tdSet, cnt);
            else {
                splashModule(false);
                $("#sysMsg").html("同步完成。"); setTimeout(function () { $("#sysMsg").html(""); }, 10000);
            }
        }//success结束
    });

    
}

//对获取的数据进行预处理，使其保持在固定的位置。
//data 获取到的json对象;tdDate 当前所处的日期格
//return 处理过的json对象

function dataPretreatment(currentNoteData,tdElement) {
    var tdDate = getDate($(tdElement).attr("id"));
    
    var i = 0;
    while(i<$(currentNoteData).length) {
        var newIndex = currentNoteData[i].pkid;//当前序列
        if (newIndex != -1) {
            var beginDate = $(currentNoteData)[i].start;
            //当开始日期不是当前所属格子的日期时
            if ((getDate(beginDate).getFullYear() < tdDate.getFullYear()) || (getDate(beginDate).getMonth() - 1 < tdDate.getMonth() - 1) || (getDate(beginDate).getDate() < tdDate.getDate())) {
                var firstTdDate = getDate($(tdElement).parent("tr").children().first().attr("id"));
                var noteDate = getDate(beginDate);
                var byQuary;
                
                //当前记事日期小于该行TR的第一格TD时 ，取第一格TD的定位
                if ((noteDate.getFullYear() < firstTdDate.getFullYear() )||(noteDate.getMonth() - 1 < firstTdDate.getMonth() - 1 )|| (noteDate.getDate() < firstTdDate.getDate())) {
                    byQuary = $(tdElement).parent("tr").children().first().find(".index div");
                    
                }
                else {
                    var year = getDate(beginDate).getFullYear();
                    var month = getDate(beginDate).getMonth() + 1;
                    var date = getDate(beginDate).getDate();
                    byQuary = $(tdElement).parent("tr").children("#"+year+"-"+month+"-"+date).find(".index div");
                   
                }

                //定位轴
                
                for (j = 0; j < $(byQuary).length; j++) {

                    if (currentNoteData[i].pkid == $(byQuary[j]).html()) {
                        if (i != j) {
                            if (currentNoteData[j] == undefined) {
                                while (j != $(currentNoteData).length - 1) {
                                    currentNoteData.push({ "pkid": "-1" });
                                }
                            }

                            if (currentNoteData[j].pkid != "-1") {
                                currentNoteData.push(currentNoteData[j]);
                                
                            }
                            currentNoteData.splice(j, 1, currentNoteData[i]);

                            currentNoteData.splice(i, 1, { "pkid": "-1" });
                        }
                    }
                }
            }
           
        }
        i++;
    }

    var cnt = $(currentNoteData).length > 3 ? 3 : $(currentNoteData).length;
    for (n = 0; n < cnt; n++) {
        if (currentNoteData[n].pkid == "-1") {
            for (m = 0; m < $(currentNoteData).length; m++) {
                if (currentNoteData[m].pkid != "-1" && (getDate(currentNoteData[m].start).getFullYear() == tdDate.getFullYear() && getDate(currentNoteData[m].start).getMonth() == tdDate.getMonth() && getDate(currentNoteData[m].start).getDate() == tdDate.getDate())) {
                    currentNoteData[n] = currentNoteData[m];
                    currentNoteData.splice(m, 1);
                    break;
                }
            }
        }
    }

    return currentNoteData;
}

///////////////////////////////////////////////////////////////////////////////////////
//周视图
//////////////////////////////////////////////////////////////////////////////////////
function weekViewHead() {
}

function weekViewBody() {

}

///////////////////////////////////////////////////////////////////////////////////////
//日视图
//////////////////////////////////////////////////////////////////////////////////////

//previousDate 上一个日期，方向（1-向后  2-向前）
function dayView(previousDate, where) {
    
    
    mode = 34;

    $("#dayView").remove();
    $(".caler").append("<div id='dayView'><div id='dayView-head'><div class='div-nav-left'><img id='nav-previous-day' src='images/ArrowHead-Left.png'/></div><div class='div-title-day'><label id='currentDay'>今天</label></div><div class='div-title-day'><label id='nextDay'>明天</label></div><div class='div-nav-right'><img id='nav-next-day' src='images/ArrowHead-Right.png'/></div></div><div id='dayView-body'><div class='leftDay'><table class='table-day' id='table-left'></table></div><div class='rightDay'><table class='table-day' id='table-left'></table></div></div></div>");
    
    //当前时间赋值
    if (previousDate==undefined) {
        $("#currentDay").attr("class", new Date().getFullYear() + "年" + (new Date().getMonth() + 1) + "月" + new Date().getDate() + "日");
        $("#nextDay").attr("class", calNextDay($("#currentDay").attr("class"), 1).year + "年" + calNextDay($("#currentDay").attr("class"), 1).month + "月" + calNextDay($("#currentDay").attr("class"), 1).date + "日");
    } else {
        if (where == 1) {
            $("#currentDay").attr("class", getDate(previousDate).getFullYear() + "年" + (getDate(previousDate).getMonth() + 1) + "月" + getDate(previousDate).getDate() + "日").text(calNextDay(previousDate, 0).day);
            $("#nextDay").attr("class", calNextDay($("#currentDay").attr("class"), 1).year + "年" + calNextDay($("#currentDay").attr("class"), 1).month + "月" + calNextDay($("#currentDay").attr("class"), 1).date + "日").text(calNextDay($("#currentDay").attr("class"), 1).day);
        }
        if (where == 2) {
            $("#currentDay").attr("class", calNextDay(previousDate, 2).year + "年" + calNextDay(previousDate, 2).month + "月" + calNextDay(previousDate, 2).date + "日").text(calNextDay(previousDate, 2).day);
            $("#nextDay").attr("class", getDate(previousDate).getFullYear() + "年" + (getDate(previousDate).getMonth() + 1) + "月" + getDate(previousDate).getDate() + "日").text(calNextDay(previousDate, 0).day);
        }
    }

    if ((getDate($("#currentDay").attr("class")).getFullYear() == new Date().getFullYear()) && (getDate($("#currentDay").attr("class")).getMonth() == new Date().getMonth()) && (getDate($("#currentDay").attr("class")).getDate() == new Date().getDate())) {
        $("#currentDay").text("今天");
    }
    if ((getDate($("#nextDay").attr("class")).getFullYear() == new Date().getFullYear()) && (getDate($("#nextDay").attr("class")).getMonth() == new Date().getMonth()) && (getDate($("#nextDay").attr("class")).getDate() == new Date().getDate())) {
        $("#nextDay").text("今天");
    }

    var tomorrow=calNextDay(new Date().getFullYear()+"-"+(new Date().getMonth()+1)+"-"+new Date().getDate(),1);
    if((getDate($("#nextDay").attr("class")).getFullYear()==tomorrow.year)&&(getDate($("#nextDay").attr("class")).getMonth()+1 == tomorrow.month) && (getDate($("#nextDay").attr("class")).getDate() == tomorrow.date)){
        $("#nextDay").text("明天");
    }
    if ((getDate($("#currentDay").attr("class")).getFullYear() == tomorrow.year) && (getDate($("#currentDay").attr("class")).getMonth()+1 == tomorrow.month) && (getDate($("#currentDay").attr("class")).getDate() == tomorrow.date)) {
        $("#currentDay").text("明天");
    }
   
    
    var $table = $(".table-day");
    var $dateTitle = $(".div-title-day");
    for (z = 0; z < $table.length; z++) {

        $($table[z]).append("<tr class='table-title'><td class='td-time'></td><td class='date-td'><label id='td-date'>" + $($dateTitle[z]).children().attr("class") + "</label></td></tr>");

        if ((getDate($($dateTitle[z]).children().attr("class")).getFullYear() == new Date().getFullYear()) && (getDate($($dateTitle[z]).children().attr("class")).getMonth() == new Date().getMonth()) && (getDate($($dateTitle[z]).children().attr("class")).getDate() == new Date().getDate()))
            $($table[z]).find(".date-td").css({ "background": "#757575", "color": "white" });
        else {
            $($table[z]).find(".date-td").css({ "background": "#F0F0F0", "color": "#606060" });
            
        }

        $($table[z]).append("<tr class='table-title'><td class='td-time'></td><td></td></tr>");

        dayViewDataLoad($($table[z]), $($dateTitle[z]).children().attr("class"));
    }

    

    //天视图样式
    $("#dayView").css({ "position": "absolute", "height": $caler.parent().height(), "width": $caler.parent().width(), "z-index": "1", "top": $caler.parent().offset().top, "left": $caler.parent().offset().left, "background": "#F0F0F0", "overflow": "hidden" });
    $("#dayView-head").css({ "width": "100%", "height": "10%", "padding-top": "15px","padding-bottom":"2px", "overflow": "hidden" });
    $("#dayView-body").css({ "width": "100%","clear":"left","overflow":"hidden","height":"90%"});
    $(".leftDay,.rightDay").css({ "width":"50%", "height": "100%", "float": "left", "background": "white","overflow":"hidden"});
    $(".table-day").css({ "width": $(".leftDay").width()+4, "border-spacing": "3px", "margin-left": "-3px" });
    $(".table-day:eq(1)").css("margin-left","0px");
    $(".table-title td[class!='date-td']").css({ "height": "20px", "background": "#F0F0F0", "color": "#606060" });
    $(".td-time").css({"width":"50px"}); //

    $(".div-title-day:eq(1)").css({"margin-left":"37.5%"});


    $("#dayView-head img").css({ "height": "40px", "width": "40px", "cursor": "pointer" }).hover(function () {
        if ($(this).attr("id") == "nav-next-day") {
            $(this).attr("src", "images/ArrowHead-Right-Hover.png");
        }
        else {
            $(this).attr("src", "images/ArrowHead-Left-Hover.png");
        }
    }, function () {
        if ($(this).attr("id") == "nav-next-day") {
            $(this).attr("src", "images/ArrowHead-Right.png");
        }
        else {
            $(this).attr("src", "images/ArrowHead-Left.png");
        }

    }).mousedown(function () {
        if ($(this).attr("id") == "nav-next-day")
            $(this).attr("src", "images/ArrowHead-Right-Click.png");
        else
            $(this).attr("src", "images/ArrowHead-Left-Click.png");
    }).mouseup(function () {
        if ($(this).attr("id") == "nav-next-day") {
            $(this).attr("src", "images/ArrowHead-Right.png");
        }
        else {
            $(this).attr("src", "images/ArrowHead-Left.png");
        }

    });

    $(".div-nav-left").css({ "float": "left", "padding-top": "8px", "width": "40px" });
    $(".div-title").css({ "font-size": "40px", "color": "#606060", "float": "left", "padding-left": "15px" });
    $(".div-nav-right").css({ "float": "right", "padding-top": "8px", "width": "40px" });

    $(".div-title-day").css({ "font-size": "40px", "color": "#606060", "float": "left", "padding-left": "15px" });
    dayViewNavEven();

    
}

//天视图导航按钮事件
function dayViewNavEven() {
    var mouseDown = 1; //记录鼠标按下的时长(2-快速 10-高速）
    var timer;
    $("#nav-previous-day").click(function () {
        dayView($("#currentDay").attr("class"),2);
    }).mousedown(function () {
        timer = setInterval(function () {
            if (mouseDown >= 2) {
                dayView($("#currentDay").attr("class"), 2);
            }
            mouseDown++;
        }, 300);
    }).mouseup(function () {
        if (mouseDown >= 2) {
            //惯性回滚
            dayView($("#nextDay").attr("class"), 1);
        }
        mouseDown = 0;//恢复默认值
        clearInterval(timer);
    }).mouseout(function () {
        mouseDown = 0;
        clearInterval(timer);
    });

    //后翻
    $("#nav-next-day").click(function () {
        dayView($("#nextDay").attr("class"), 1);
    }).mousedown(function () {
        timer = setInterval(function () {
            if (mouseDown >= 2) {
                dayView($("#nextDay").attr("class"), 1);
                
            }
            mouseDown++;
        }, 300);
    }).mouseup(function () {
        if (mouseDown >= 2) {
            //惯性回滚
            dayView($("#currentDay").attr("class"), 2);
            
        }
        mouseDown = 0;
        clearInterval(timer);
    }).mouseout(function () {
        mouseDown = 0;
        clearInterval(timer);

    });
}

//计算后一天返回相关数据
//date 校准日期，where 方向(0 当前 1后一天 2前一天)
function calNextDay(date,where){
    var y = getDate(date).getFullYear();
    var m = getDate(date).getMonth();
    var d = Number(getDate(date).getDate());
    var whereDay;
    if (where == 1) {
        whereDay = new Date(y, m, (d + 1));
    }
    if (where == 2) {
        whereDay = new Date(y, m, (d -1));
    }
    if (where == 0) {
        whereDay = new Date(y, m, d);
    }

    var day;
    switch (whereDay.getDay()){
        case 0:
            day="星期日";
            break;
        case 1:
            day="星期一";
            break;
        case 2:
            day="星期二";
            break;
        case 3:
            day="星期三";
            break;
        case 4:
            day="星期四";
            break;
        case 5:
            day="星期五";
            break;
        case 6:
            day="星期六";
            break;
       
    }

    return { "year": whereDay.getFullYear(), "month": whereDay.getMonth() + 1, "date": whereDay.getDate(), "day":day  };
}

//天视图数据加载模块
function dayViewDataLoad(element,date) {
    var dateNow = getDate(date).getFullYear() + "-" + (getDate(date).getMonth() + 1) + "-" + getDate(date).getDate();
    //获取当前时间数据
    $.ajax({
        url: "NoteDB.asmx/GetNote",
        type: "post",
        data: { "date": dateNow,"user":userId },
        success: function (result) {
            //alert(result);
            if ($(result).children("string").text() != "[]"&&$(result).children("string").text() != "") {
                var json = eval("(" + $(result).children("string").text() + ")");
                for (b = 0; b < json.length; b++) {
                    var state = json[b].state;
                    var note = json[b].note;
                    var begin = json[b].start;
                    var end = json[b].end;
                    $(element).append("<tr class='table-body'><td class='td-seq'>" + (b + 1) + "</td><td><div class='day-note'>" + note + "</div></td></tr>");
                    if (state == 1) {
                        $($(element).find(".day-note")[b]).css({ "background": "#008A00" }).attr("title",note+"\n"+begin+" 到 "+end);
                    }
                    //进行中
                    if (state == 0 && ((getDate(end).getFullYear() > new Date().getFullYear()) || (getDate(end).getMonth() > (new Date().getMonth()+1)) || (getDate(end).getDate() > new Date().getDate()))) {
                        $($(element).find(".day-note")[b]).css({ "background": "#2671EB" }).attr("title", note + "\n" + begin + " 到 " + end);
                    }
                    //超时
                    if (state == 0 && ((getDate(end).getFullYear() < new Date().getFullYear()) || (getDate(end).getMonth() < (new Date().getMonth()+1)) || (getDate(end).getDate() < new Date().getDate()))) {
                        $($(element).find(".day-note")[b]).css({ "background": "#AC193D" }).attr("title", note + "\n" + begin + " 到 " + end);
                    }

                    $(element).find(".day-note").css({ "height": "100%", "width": "96.75%", "color": "white", "padding": "10px" });
                    $(element).find(".td-seq").css({ "text-align": "center", "font-size": "16px", "color": "#606060" });
                    
                    $(element).find(".table-body td").css({ "height": "20px", "background": "#F0F0F0", "overflow": "hidden","font-size":"14px" });
                }

                //根据行数调整下拉条显示
                $(".table-body").each(function (i) {
                    if ($($(".table-day")[i]).height() > $(".leftDay").height()) {
                        if (i == 0)
                            $(".leftDay").css("overflow", "scroll");
                        if (i == 1)
                            $(".rightDay").css("overflow", "scroll");
                    }
                });
            }
        },
        cache: true
    });
}



/////////////////////////////////////////////////////////////////////////////////////
//新建记事添加页面
/////////////////////////////////////////////////////////////////////////////////////
function newNoteView() {
    $caler.append("<div id='newNote'></div>");


    //样式
    $("#newNote").css({"position":"absolute","top":"0","left":"0","background":"red","z-index":"10","height":"100%","width":"100%"});
}

//帮助界面
function help() {
    $caler.append("<div id='help'></div>");
    if(mode==1)
        $monthHelp = $("<div id='help-month'><div><img src='images/Tooltips.png'/></div><div >每天的事件进度摘要<br/>当事件数量大于3条时，会予以提示进去天视图查看详细记录<br/><span style='color:#2671EB'>蓝</span>、<span style='color:#008A00'>绿</span>、<span style='color:#AC193D'>红</span>三色条分别代表进行中、已完成和过期的三种状态</div></div>").css({ "position": "absolute", "top": $("td[class!='month-title']:eq(7)").offset().top + 20, "left": $("td[class!='month-title']:eq(8)").offset().left, "text-align": "left" });
    $mouseClickTip = $("<div id='help-mc'><div><img src='images/Mouse Operation.png'/></div><div class='help-text'>任意处右击可以打开底部功能选项菜单</div></div>").css({ "position": "absolute", "top": "80%", "left": $("td[class!='month-title']:eq(9)").offset().left });
    $mouseRight = $("<div id='help-r'><div><img src='images/Navigation-Down-Right.png'/></div><div class='help-text'>鼠标滑动到右下角打开设置菜单</div></div>").css({ "position": "absolute", "top": $caler.height()-80, "left": $caler.width()-370 });
    $dateClick = $("<div id='help-mc'><div><img src='images/Navigation-Up-Left.png'/></div><div class='help-text'>单击日期可以快速自定义到所需的日期</div></div>").css({ "position": "absolute", "top": $("#currentDate").offset().top + $("#currentDate").height() -20, "left": $("#currentDate").offset().left + $("#currentDate").width()-20 });
    $("#help").append($mouseClickTip).append($mouseRight).append($dateClick).append($monthHelp);
    $("#help").css({ "position": "absolute", "top": $caler.offset().top, "left": $caler.offset().left, "background": "black", "z-index": "52", "height": $caler.parent().height(), "width": $caler.parent().width(), "text-align": "center", "color": "white", "opacity": "0.8" ,"font-size":"20px"}).click(function () { $(this).remove(); });
    $("#help").find("img").css({ "height": "80px", "width": "80px" });
    $("#help div div").css({ "float": "left" });
    $("#help-r div").css({"float":"right"});
    $(".help-text").css({ "padding-top": "30px" });


    
}

////////////////////////////////////////////////////////////////////////////////////
//工具条界面
///////////////////////////////////////////////////////////////////////////////////
function configUI() {
    //布局地图  div>div(viewMode)&div(toolBtn)>img&span
    var $controlPanel = $("<div id='toolbar'><div class='viewMode'><div><img src='images/Day View.png' id='go_dayView'/></div><span>天</span></div><div class='viewMode'><div><img src='images/Month View.png' id='go_monthView'/></div><span>月</span></div><div class='toolBtn'><div><img id='go_today' src='images/Calendar.png'/></div><span>今天</span></div></div>");

    //<div class='viewMode'><div><img src='images/Week View.png' id='go_weekView'/></div><span>周</span></div>
    //<div class='toolBtn'><div><img src='images/Add.png' id='add_note'/></div><span>新建</span></div>
    $(".caler").append($controlPanel);

    //事件触发
    $("#add_note").click(function () { alert('当前版本不支持此功能。');});
    $("#go_today").click(function () { 
    if (mode == 34) 
        dayView(); 
    if (mode == 1) 
    {   isFrist = false; 
        loadHeadView(); } 
    });
    $("#go_dayView").click(function () { dayView(); });
    $("#go_monthView").click(function () { 
        mode = 1; 
        $("#dayView").animate({ "marginLeft": $caler.parent().width(),"width":0}, 1000, function () {
            $(this).remove();})});
    $("#go_weekView").click(function () { alert('当前版本不支持此功能。');});

    //底部工具条样式
    var toolH = $(".caler").height() * 0.12;
    var topH = $(".caler").height() - toolH+$caler.parent().offset().top;
    $("#toolbar").css({ "background": "#757575", "height": toolH, "width": $caler.parent().width(), "position": "absolute", "z-index": "51", "top": topH, "overflow": "hidden" ,"left":$caler.offset().left,"opacity":"1"});

    var imgSize = $("#toolbar").height() * 0.45;
    var divSize = $("#toolbar").height() * 0.8;
    $(".viewMode").css({ "float": "left", "margin": "15px 15px 10px 15px", "height": divSize, "width": divSize,"text-align":"center" });
    $(".toolBtn").css({ "float": "right", "margin": "15px 15px 10px 15px", "height": divSize, "width": divSize, "text-align": "center" });
    $("#toolbar span").css({"color":"white","font-size":"12px","margin-top":"-5px"});
    $("#toolbar img").css({ "height": imgSize, "width": imgSize, "cursor": "pointer" }).hover(function () {
        if($(this).attr("id")=="add_note")
            $(this).attr("src", "images/Add-Hover.png");
        else if ($(this).attr("id") == "go_dayView")
            $(this).attr("src", "images/Day View-Hover.png");
        else if ($(this).attr("id") == "go_weekView")
            $(this).attr("src", "images/Week View-Hover.png");
        else if ($(this).attr("id") == "go_monthView")
            $(this).attr("src", "images/Month View-Hover.png");
        
    }, function () {
        if ($(this).attr("id") == "add_note")
            $(this).attr("src", "images/Add.png");
        else if ($(this).attr("id") == "go_today")
            $(this).attr("src", "images/Calendar.png");
        else if ($(this).attr("id") == "go_dayView")
            $(this).attr("src", "images/Day View.png");
        else if ($(this).attr("id") == "go_weekView")
            $(this).attr("src", "images/Week View.png");
        else if ($(this).attr("id") == "go_monthView")
            $(this).attr("src", "images/Month View.png");
        
    });

}




////
//侧边栏
///
function siderbar() {
    $caler.append("<div class='siderbar'></div>")
        var h = $caler.width() * 0.3;
        $(".siderbar").append("<div class='side-name'>设置</div><div class='side-about'>日历 1.0 Beta 1022<br/>迈志科技</div><div class='side-menu' id='ccount'>绑定ＱＱ账号</div><div class='side-menu' id='feedback'>反馈</div>").css({ "z-index": "50", "overflow":"hidden","background": "#232323", "width": 0, "height": $caler.height(), "position": "absolute", "top": $caler.parent().offset().top, "left": $caler.parent().offset().left + $caler.width() }).animate({ "left": $caler.parent().offset().left+$caler.width() - h,"width":h }, 500);
    //<div class='side-menu' id='sider-option'>选项</div>
        $(".side-name").css({ "color": "white", "font-size": "30px", "padding": "30px 30px 15px 30px", "overflow": "hidden" });
        $(".side-about").css({ "font-size": "14px", "color": "#A7A7A7", "padding": "15px 30px 15px 30px", "overflow": "hidden" });
        //$("#menu-top").css({ "border": "2px solid white" });
        $(".side-menu").css({ "color": "white", "font-size": "14px", "padding": "15px 30px 15px 30px", "overflow": "hidden" }).hover(function () { $(this).css({ "background": "#3F3F3F" }) }, function () { $(this).css({ "background": "#232323" }) }).mouseenter(function () { $(".side-menu").css({ "border": "0px" }) });

        $("#sider-option").click(function () { alert("当前版本不提供此功能。"); });
        $("#feedback").click(function () { location.href = "mailto:tiger.wang@mobizone.cn?subject=使用反馈"; });
}


///
///闪屏
///
function splashModule(isValid) {
    if (isValid) {
        $splash = $("<div id='splash'><img src='images/logo.png'/><span id='splash-tip'></span><span id='logo'>迈志科技</div></div>").css({ "position": "absolute", "top": $caler.parent().offset().top, "left": $caler.parent().offset().width, "background": "#2671EB", "z-index": "100", "height": $caler.parent().height(), "width": $caler.parent().width(), "text-align": "center", "color": "white", "overflow": "hidden" });
        
        $splash.find("#splash-tip").css({ "position": "absolute", "top": $caler.offset().top + $caler.parent().height() - 80, "left": $caler.offset().left + $caler.parent().width() * 0.35, "z-index": "101" });
        $splash.find("#logo").css({ "position": "absolute", "top": $caler.parent().height() - 30, "left": $caler.parent().width() * 0.47, "z-index": "101" });
        $splash.find("img:eq(0)").css({"height":"180px","width":"180px","margin-top":"15%"});

        var random = parseInt( Math.random() * 10);
        //alert(random);
        switch (random) {
            case 1:
                $splash.find("#splash-tip").html("小提示：当天的事件数量超过3件时，会在日期右上角标注。");
                break;
            case 2:
                $splash.find("#splash-tip").html("小提示：右击日历的任何地方都可以调出功能菜单。");
                break;
            case 3:
                $splash.find("#splash-tip").html("小提示：鼠标指向日历右下角可以弹出设置菜单。");
                break;
            case 4:
                $splash.find("#splash-tip").html("小提示：一个多天连续的事件将以连续的块状标示。");
                break;
            case 5:
                $splash.find("#splash-tip").html("小提示：长按月份切换按钮不放会自动滚动。");
                break;
            case 6:
                $splash.find("#splash-tip").html("小提示：点击月份标头可以自定义到你选择的日期。");
                break;
            case 7:
                $splash.find("#splash-tip").html("小提示：任何时候遇到使用问题都可以点击[帮助]按钮。");
                break;
            case 8:
                $splash.find("#splash-tip").html("小提示：使用中的任何问题都可以点击[反馈]按钮告诉我们。");
                break;
            case 9:
                $splash.find("#splash-tip").html("小提示：浏览器可视区域保持在1024*768以上将更方便您的使用。");
                break;
            case 0:
                $splash.find("#splash-tip").html("小提示：不同颜色的色块标示该事件当前的状态。");
                break;
            
        }

        $caler.append($splash);
    }
    else {
        //"marginTop": 0-$(this).height()-$caler.parent().offset().top
       $("#splash").animate({ "marginTop": $caler.parent().height(), "height": 0 }, 2000, function () { $(this).remove(); });
        
//       $("#splash").animate({ height: "-=90" }, "slow", function () {

//                $("#splash").remove()});

    }
}

//模块
///节日模块
function holidayModule() {
    //预留功能
}

//邮件提醒模块
function mailCall() {
    //预留功能
}

//短信提醒
function messageCal() {
    //预留功能
}

//万年历模块
function chineseCaler() {
    //预留功能
}



/////////////////////////////////////////////////
//布局样式&动画效果
////////////////////////////////////////////////
function globalStyle() {
    ///通用样式
    $($(".caler")[0]).css({ "height": "100%", "width": "100%", "font": "16px '微软雅黑'", "overflow": "hidden", "background": "#F0F0F0" }).append("<div id='binbong'></div>").click(function () {
        $(".siderbar").animate({ "left": $caler.width() }, 500).remove();
        $("#toolbar").remove();
    });
    $("#binbong").css({ "width": 10, "height": 10, "position": "absolute","z-index":"5px" ,"top": $caler.height() - 10, "left": $caler.width() - 10 }).mouseenter(function () {
        siderbar();
    });
    $("#sysMsg").css({ "height": "15px", "padding-left": "55px", "color": "#606060" ,"float":"left"});
    $("#quickLink").css({ "cursor": "pointer", "float": "right", "color": "#606060", "height": "15px", "padding-right": "55px" }).click(function () { help(); });
    //头部
    $(".caler-head").css({ "height": "9%", "width": "100%", "padding-top": "5px", "overflow": "hidden" });

    //导航按钮
    $(".caler-head img").css({ "height": "40px", "width": "40px", "cursor": "pointer" }).hover(function () {
        if ($(this).attr("id") == "nav-next") {
            $(this).attr("src", "images/ArrowHead-Right-Hover.png");
        }
        else {
            $(this).attr("src", "images/ArrowHead-Left-Hover.png");
        }
    }, function () {
        if ($(this).attr("id") == "nav-next") {
            $(this).attr("src", "images/ArrowHead-Right.png");
        }
        else {
            $(this).attr("src", "images/ArrowHead-Left.png");
        }

    }).mousedown(function () {
        if ($(this).attr("id") == "nav-next")
            $(this).attr("src", "images/ArrowHead-Right-Click.png");
        else
            $(this).attr("src", "images/ArrowHead-Left-Click.png");
    }).mouseup(function () {
        if ($(this).attr("id") == "nav-next") {
            $(this).attr("src", "images/ArrowHead-Right.png");
        }
        else {
            $(this).attr("src", "images/ArrowHead-Left.png");
        }

    });

    $(".div-nav-left").css({ "float": "left", "padding-top": "8px", "width": "40px" });
    $(".div-title").css({ "font-size": "40px", "color": "#606060", "float": "left", "padding-left": "15px" });
    $(".div-nav-right").css({ "float": "right", "padding-top": "8px", "width": "40px" });

    
    //主体
    var calerBodyH = $(".caler").height() - $(".caler-head").height()-18;//容器-头部+误差值
    $(".caler-body").css({ "height": calerBodyH, "width": "100%", "color": "#606060", "overflow": "hidden", "background": "white" });

    $(".table-month").css({ "border": "0px", "margin-top": "-7px", "margin-left": "-3px", "border-spacing": "3px", "width": $(".caler-body").width() + 6, "table-layout": "fixed" });
    //表头
    $(".month-title").css({ "height": "20px","background": "#F0F0F0","padding-left": "10px", "padding-bottom": "2px" });

    //表体
    var tdH = ($(".caler-body").height() - $(".month-title").height() - 13 - 4 * rows) / rows;//行高=（容器高度-标头-误差-行间距*行数）/行数
    $(".table-month td[class!='month-title']").css({"height": tdH,"padding":"0px"});

    //上下月
    $(".nextMonth,.previousMonth").css({ "background": "#E4E4E4" ,"font-size":"0px"});
    //本月
    $(".currentMonth").css({ "background": "#F0F0F0", "font-size": "0px"});
    //当日
    $(".currentDay").css({ "background": "#757575", "font-size": "0px"});

    
}

//月视图单天样式  及转天视图入口
function styleForMonthGrid() {
    $(".dayGrid-head").css({ "height": "25%", "padding-left": "10px", "padding-right": "10px" ,"font-size":"14px","overflow":"hidden"});
   
    $(".dayGrid-day").css({ "float": "left", "margin-top": "5%" });
    $(".dayGrid-title").css({ "float": "right", "font-size": "12px", "margin-top": "5%", "cursor": "pointer" }).click(function () {
        dayView($(this).parent().parent().attr("id"), 1)
    });


    $(".note0,.note1,.note2").css({ "position": "relative", "height": "25%", "padding-left": "10px", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "overflow": "hidden", "vertical-align": "middle", "line-height": "150%" }).click(function () {
        dayView($(this).parent("td").attr("id"), 1);
    });
    //fillNoteStyle();
    $(".note-time").css({ "width": "1%", "float": "left", "margin-top": "5%","display":"none"});
    $(".note-summary").css({ "width": "80%", "float": "left", "margin-top": "5%" });
    $(".index").css({"display":"none"});
}

function fillNoteStyle() {

    //IE兼容模式下有错位问题
    //单天已完成
    $(".note-single-finish").css({ "position": "relative", "background": "#008A00", "height": "25%", "padding-left": "10px", "color": "white", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "cursor": "pointer", "overflow": "hidden" }).hover(function () {
        $(this).css({ "background": "#219921" });
    }, function () {
        $(this).css({ "background": "#008A00" });
    });

    //单天超时
    $(".note-single-timeout").css({ "position": "relative", "background": "#AC193D", "height": "25%", "padding-left": "10px", "color": "white", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "cursor": "pointer", "overflow": "hidden" }).hover(function () {
        $(this).css({ "background": "#B73756" });
    }, function () {
        $(this).css({ "background": "#AC193D" });
    });

    //单天进行中
    $(".note-single-running").css({ "position": "relative", "background": "#2671EB", "height": "25%", "padding-left": "10px", "color": "white", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "cursor": "pointer", "overflow": "hidden" }).hover(function () {
        $(this).css({ "background": "#4283EE" });
    }, function () {
        $(this).css({ "background": "#2671EB" });
    });

    //多天已完成(对相对定位对象的改变使其改变自身宽度达到跨列效果）
    $(".note-multi-finish").css({ "position": "relative", "background": "#008A00", "height": "25%", "width": "100%", "padding-left": "10px", "color": "white", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "cursor": "pointer", "overflow": "hidden" }).hover(function () {
        //$(this).css({ "background": "#219921" });
    }, function () {
        //$(this).css({ "background": "#008A00" });
    });

    //多天超时
    $(".note-multi-timeout").css({ "position": "relative", "background": "#AC193D", "height": "25%", "width": "100%", "padding-left": "10px", "color": "white", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "cursor": "pointer", "overflow": "hidden" }).hover(function () {
        //$(this).css({ "background": "#D85F42" });
    }, function () {
        // $(this).css({ "background": "#D24726" });
    });

    //多天进行中
    $(".note-multi-running").css({ "position": "relative", "background": "#2671EB", "height": "25%", "width": "100%", "padding-left": "10px", "color": "white", "padding-right": "10px", "font-size": "14px", "margin-top": "1px", "cursor": "pointer", "overflow": "hidden" }).hover(function () {
        //$(this).css({ "background": "#4283EE" });
    }, function () {
        //$(this).css({ "background": "#2671EB" });
    });
}

